{extend name="common/base"}
{block name="title"}新增轮播图{/block}
{block name="content"}

        <!-- 内容区域 -->
        <div class="tpl-content-wrapper">


            <div class="row-content am-cf">


                <div class="row">

                    <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                        <div class="widget am-cf">
                            <div class="widget-head am-cf">
                                <div class="widget-title am-fl">新增轮播图</div>
                                <div class="widget-function am-fr">
                                    <a href="javascript:;" class="am-icon-cog"></a>
                                </div>
                            </div>
                            <div class="widget-body am-fr">

                                <form class="am-form tpl-form-line-form" action="{:url('store')}" method="post" enctype="multipart/form-data">
                                    <div class="am-form-group">
                                        <label for="user-name" class="am-u-sm-3 am-form-label">描述 <span class="tpl-form-line-small-title">Desc</span></label>
                                        <div class="am-u-sm-9">
                                            <input type="text" class="tpl-form-input" id="user-name" placeholder="请输入描述文字" name="desc">
                                            <small>请填写描述文字5-10字左右。</small>
                                        </div>
                                    </div>

                                    <div class="am-form-group">
                                        <label for="user-email" class="am-u-sm-3 am-form-label">排序 <span class="tpl-form-line-small-title">Ord</span></label>
                                        <div class="am-u-sm-9">
                                            <input type="number" class="tpl-form-input" value="0"  name="ord">
                                        </div>
                                    </div>


                                    <div class="am-form-group">
                                        <label class="am-u-sm-3 am-form-label">跳转地址 <span class="tpl-form-line-small-title">url</span></label>
                                        <div class="am-u-sm-9">
                                            <input type="text" placeholder="输入跳转地址" class="tpl-form-input" name="url">
                                        </div>
                                    </div>

                                    <div class="am-form-group">
                                        <label for="user-weibo" class="am-u-sm-3 am-form-label">封面图 <span class="tpl-form-line-small-title">Images</span></label>
                                        <div class="am-u-sm-9">
                                            <div class="am-form-group am-form-file">
                                                <div class="tpl-form-file-img">
                                                    <img id="preview" src="__STATIC__/admin/assets/img/a5.png" alt="">
                                                </div>
                                                <button type="button" class="am-btn am-btn-danger am-btn-sm">
    <i class="am-icon-cloud-upload"></i> 添加封面图片</button>
                                                <input id="doc-form-file" type="file" multiple="" name="src">
                                                <input type="hidden" name="src2">
                                            </div>

                                        </div>
                                    </div>

                                    <div class="am-form-group">
                                        <div class="am-u-sm-9 am-u-sm-push-3">
                                            <button type="submit" class="am-btn am-btn-primary tpl-btn-bg-color-success ">提交</button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
{/block}
{block name="footer-js"}
<script>
    $('#doc-form-file') .change(function() {
        var file = document.querySelector('#doc-form-file').files[0];
        var fd = new FormData();
        fd.append('src' , file);
        $.ajax({
            url: "{:url('store')}",
            type: "post",
            data: fd,
            contentType: false,
            processData: false,
            mimeType: "multipart/form-data",
            dataType:'json',
            success: function (data) {
                console.log(data);
                if (data.status == 1)
                {
                    $('#preview').attr('src' , data.src)
                    $('input[name="src2"]').val(data.savename)
                }
            }
        });
    })

</script>
{/block}